package com.example.chatroom.repository;

import com.example.chatroom.domain.ChatHistory;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;


public interface ChatHistoryRepository extends JpaRepository<ChatHistory, Long> {

    @Query(nativeQuery = true, value = "select * from chat_history " +
            "where to_user_id = 0 || to_user_id = ?1 || from_user_id = ?1")
    List<ChatHistory> getHistory(Long toUserId);

}
